package org.thanos.demo.producer;

import io.nats.client.Connection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.nio.charset.StandardCharsets;
import java.util.UUID;

@Component
public class DemoProducer {

    @Autowired
    private Connection connection;

    @Value("${spring.nats.topic}")
    private String topic;

    public void produce() {
        connection.publish(topic, UUID.randomUUID().toString().getBytes(StandardCharsets.UTF_8));
    }
}
